/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */


{%- macro to_java_type(type) -%}
  {%- if type == "string" -%}
    String
  {%- elif type == "boolean" -%}
    boolean
  {%- elif type == "number" -%}
    long
  {%- else -%}
    {{type}}
  {%- endif -%}
{%- endmacro %}
{%- macro print_value(type, value) -%}
  {{ "\"" if type == "String"}}{{value}}{{ "\"" if type == "String"}}
{%- endmacro %}
{%- macro upFirst(text) -%}
  {{ text[0]|upper}}{{text[1:] }}
{%- endmacro %}
{%- macro lowerFirst(text) -%}
  {{ text[0]|lower}}{{text[1:] }}
{%- endmacro %}

package {{pkg | trim}};

import static io.opentelemetry.common.AttributeKey.booleanKey;
import static io.opentelemetry.common.AttributeKey.longKey;
import static io.opentelemetry.common.AttributeKey.stringKey;

import io.opentelemetry.common.AttributeKey;

// DO NOT EDIT, this is an Auto-generated file from {{template}}
public final class {{class}} {
  {%- for attribute in attributes | unique(attribute="fqn") %}

  /**
  * {% filter escape %}{{attribute.brief | to_doc_brief}}.{% endfilter %}
    {%- if attribute.note %}
  *
  * Note: {% filter escape %}{{attribute.note | to_doc_brief}}.{% endfilter %}
    {%- endif %}
    {%- if attribute.deprecated %}
  *
  * @deprecated {{attribute.deprecated | to_doc_brief}}.
    {%- endif %}
  */
    {%- if attribute.deprecated %}
  @Deprecated
    {%- endif %}
  public static final AttributeKey<{{upFirst(to_java_type(attribute.attr_type))}}> {{attribute.fqn | to_const_name}} = {{lowerFirst(to_java_type(attribute.attr_type))}}Key("{{attribute.fqn}}");
  {%- endfor %}

  // Enum definitions
  {%- for attribute in attributes | unique(attribute="fqn") %}
  {%- if attribute.is_enum %}
  {%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %}
  {%- set type = to_java_type(attribute.attr_type.enum_type) %}
  {%- if attribute.attr_type.custom_values %}
  public static final class {{class_name}} {
    {%- for member in attribute.attr_type.members %}
      /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
      public static final {{ type }} {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }};
    {%- endfor %}
      private {{ class_name }}() {}
  }
  {%- else -%}
  public enum {{class_name}} {
    {%- for member in attribute.attr_type.members %}
      /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
      {{ member.member_id | to_const_name }}({{ print_value(type, member.value) }}),
    {%- endfor %}
      ;

      private final {{ type }} value;
      {{class_name}}({{ type }} value) {
        this.value = value;
      }

      public {{ type }} getValue() {
        return value;
      }
  }
  {% endif %}
  {% endif %}
  {%- endfor %}

  // Manually defined and not YET in the YAML
  /**
   * The name of an event describing an exception.
   *
   * <p>Typically an event with that name should not be manually created. Instead {@link
   * io.opentelemetry.trace.Span#recordException(Throwable)} should be used.
   */
  public static final String EXCEPTION_EVENT_NAME = "exception";

  private {{class}}() {}
}
